<?php
	/**
	 * reset randomizer
	 */
	function make_seed() {
		list($usec, $sec) = explode(' ', microtime());
		return (float) $sec + ((float) $usec * 100000);
	}

//------------------------------------------------------------//
	/**
	 * function generates 8 char string to use as password
	 *
	 * @return string
	 */
	function create_rand_str() {
		$chars = "123456789qwertyuipasdfghjkzxcvbnmQWERTYUPASDFGHJKLZXCVBNM";
		// no 'l', '0', 'o', 'I', 'O', '1' because they are disambigous
		srand(make_seed());
		$pass = "";
		for ($i = 0; $i < 8; $i++) {
			$pass .= $chars [rand(0, strlen($chars) - 1)];
		}
		return $pass;
	}

	function send_restore_email($email, $pass, $firstName) {
		require ("include/setupMail.php");
		//send email with new pass
		$to = $email;
		$subj = "New password for your Getub.com account";
		$message = "
			<a href=\"http://getub.com\"><img src=\"http://getub.com/final/images/logo.jpg\" style=\"padding-bottom: 12px;\" /></a>
			<p>Dear client,</p>
			<p>Thanks for being with Getub!</p>
			<p>New password for Your account, at <a href='http://getub.com/'>getub.com</a> is: " . $pass . "</p>
			<p>We hope you enjoy using the site,<br />The Getub Team</p>";

		$headers = "MIME-Version: 1.0" . "\r\n";
		$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

		$mailsend = mail($to, $subj, $message, $headers);
	}
?>